package org.icress.fusion.snapshot

import org.icress.fusion.b2b.Dealer
import org.icress.fusion.ws.OutBound

class CreditControlJob {

    static triggers = {
        cron name: 'CreditControlJobTrigger', cronExpression: "* 11 * * * ?"
    }
    def group = "ERP"

    def concurrent = false
    
    def execute() {
        // execute task
        def dealers = Dealer.findAllByApprovalStatus("已核准")

        for(dealer in dealers){
            new OutBound(
                objectName:'dealer'
                , objectId : dealer.id
                , method : 'creditControl'
                , asynchronous : false 
                , owner : dealer.owner
                , createdBy : dealer.owner
                , lastModifiedBy : dealer.owner
            ).save(flush:true)
        }
    }
}
